window.onload = function() {
	// banner 轮播图
	var swiper = new Swiper('.banner-box', {
		spaceBetween: 300,
		centeredSlides: true,
		autoplay: {
			delay: 5000,
			disableOnInteraction: false,
		},
		pagination: {
			el: '.swiper-pagination',
			clickable: true,
		},
		navigation: {
			nextEl: '.swiper-button-next',
			prevEl: '.swiper-button-prev',
		},
	});


	// 选项卡
	$('.nav-sub .show ').mouseout(function() {
		//切换class
		$(this).addClass('active').siblings('show').removeClass('active');
		//获取索引
		var i = $(this).index();
		//切换content
		$(this).parents('.qe').find('ul').eq(i).show().siblings('ul').hide();
		
	});
	
	
	$('.qie .title ul li').click(function() {
		//切换class
		$(this).addClass('active').siblings('li').removeClass('active');
		//获取索引
		var i = $(this).index();
		//切换content
		$(this).parents('.qie').find('.elc-box').eq(i).show().siblings('.elc-box').hide();
		
	});

	//滚动事件
	$(window).scroll(function() {
		var scrollTop = $(document).scrollTop();
		// console.log(scrollTop);
		if (scrollTop >= 550) {
			$('.head').fadeIn();
		} else {
			$('.head').fadeOut();
		}
	})

	//倒计时
	var firstIntDiff = parseInt(86400); //倒计时总秒数量

	function timer(intDiff, idName) {
		window.setInterval(function() {
			var day = 0,
				hour = 0,
				minute = 0,
				second = 0; //时间默认值     
			if (intDiff > 0) {
				hour = Math.floor(intDiff / (60 * 60)) - (day * 24);
				minute = Math.floor(intDiff / 60) - (day * 24 * 60) - (hour * 60);
				second = Math.floor(intDiff) - (day * 24 * 60 * 60) - (hour * 60 * 60) - (minute * 60);
			}
			if (second <= 9) second = '0' + second;
			$(idName + ' .hour_show').html('<s id="h"></s>' + hour );
			$(idName + ' .minute_show').html('<s></s>' + minute );
			$(idName + ' .second_show').html('<s></s>' + second );
			intDiff--;
		}, 1000);
	}

	$(function() {
		timer(firstIntDiff, '#first');
	});


	//回到顶部
	$('.head').click(function() {
		$('html,body').animate({ scrollTop: 0 }, 500);
	});
}
